#!/usr/bin/python
# -*- coding: UTF-8 -*-
import  requests
import  os

url="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556273142531&di=b2d5b520a0868a80fd7a9fffb0458070&imgtype=0&src=http%3A%2F%2Fpic29.nipic.com%2F20130601%2F12122227_123051482000_2.jpg"
root="D://pics//"
patn=root+"123.jpg"
try:
   if not os.path.exists(root):
       os.mkdir(root)
   if not os.path.exists(patn):

       r=requests.get(url)
       with open(patn,'wb') as f:
        f.write(r.content)
        f.close()
        print("文件保存成功")
   else:
       print("文件已存在")
except:
    print("爬取失败")